package com.doit.day01;

import org.apache.zookeeper.*;

public class DataNode2Demo {
    public static void main(String[] args) throws Exception {
        //首先如果有datanode启动了，那么就要向zk进行注册，增加一个节点
        String zkConnect = "linux01:2181,linux02:2181,linux03:2181";
        int timeOut = 1000;
        ZooKeeper zk = new ZooKeeper(zkConnect, timeOut, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                System.out.println("linux02上的datanode启动了......");
            }
        });


        //接下来就需要注册
        zk.create("/datanodes/linux02","datanode2".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

        //我只要增加了节点 就要去通知namenode  重新获取一下这个子节点的个数，再去做实际的业务需求 移动block块
    }
}
